const express=require("express");
const app = express();
const bodyParser=require('body-parser');
app.use(express.static('public'));
app.use(bodyParser.urlencoded({extended:true}));
app.get('/get',(req,res)=>{
    // http://localhost:3000/get?name=ysx&age=17
    console.log(req.query); 
    res.send('这是get请求')
})
app.get('/getparams/:name/:age',(req,res)=>{
    http://localhost:3000/getparams/ysx/18
    console.log(req.params);
    res.send("今天上课好困")

})
app.post('/post2',(req,res)=>{
    // http://localhost:3000/html/index1.html
    console.log(req.body)
    res.send("这是post请求")
})
app.listen(3000,err=>{
    if(!err) console.log('服务器启动成功');   
    else console.log(err);
})